package com.vhly.ddxdecompiler.dexreader.file.dalv.code.reader;

import com.vhly.ddxdecompiler.dexreader.file.dalv.code.DalvInsn;
import com.vhly.ddxdecompiler.dexreader.io.DexInputStream;

import java.io.IOException;


public final class Form21s extends InsnReader {

    public static final InsnReader THE_ONE = new Form21s();

    private Form21s() {
    }

    public void prepair(DalvInsn dalvInsn, int reg) {
        dalvInsn.addRegister(reg);
    }

    public int read(DalvInsn insn, DexInputStream din) throws IOException {
        short c1 = din.readShort();
        insn.addRegister(c1);
        return 1;
    }

    //    public String insnArgString(DalvInsn insn) {
//        RegisterSpecList regs = insn.getRegisters();
//        CstLiteralBits value = (CstLiteralBits) ((CstInsn) insn).getConstant();
//        return (new StringBuilder()).append(regs.get(0).regString()).append(", ").append(literalBitsString(value)).toString();
//    }
//
//    public String insnCommentString(DalvInsn insn, boolean noteIndices) {
//        CstLiteralBits value = (CstLiteralBits) ((CstInsn) insn).getConstant();
//        return literalBitsComment(value, 16);
//    }
//
//    public int codeSize() {
//        return 2;
//    }
//
//    public boolean isCompatible(DalvInsn insn) {
//        RegisterSpecList regs = insn.getRegisters();
//        if (!(insn instanceof CstInsn) || regs.size() != 1 || !unsignedFitsInByte(regs.get(0).getReg()))
//            return false;
//        CstInsn ci = (CstInsn) insn;
//        com.android.dx.rop.cst.Constant cst = ci.getConstant();
//        if (!(cst instanceof CstLiteralBits)) {
//            return false;
//        } else {
//            CstLiteralBits cb = (CstLiteralBits) cst;
//            return cb.fitsInInt() && signedFitsInShort(cb.getIntBits());
//        }
//    }
//
//    public InsnFormat nextUp() {
//        return Form21h.THE_ONE;
//    }
//
//    public void writeTo(AnnotatedOutput out, DalvInsn insn) {
//        RegisterSpecList regs = insn.getRegisters();
//        int value = ((CstLiteralBits) ((CstInsn) insn).getConstant()).getIntBits();
//        write(out, opcodeUnit(insn, regs.get(0).getReg()), (short) value);
//    }

}